package com.itheima.htmo_01.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.htmo_01.dto.QuestionsDTO;
import com.itheima.htmo_01.dto.QuestionsPageDTO;
import com.itheima.htmo_01.pojo.Result;
import com.itheima.htmo_01.service.QuestionsService;
import com.itheima.htmo_01.vo.QuestionsPageVO;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@CrossOrigin(origins = "*")
@RestController
public class PublishController {

    @Resource
    private QuestionsService questionsService;

    @PostMapping("/publish")
    public Result<String> publish(@RequestBody QuestionsDTO questionsDTO){

        questionsService.saveQuestion(questionsDTO);

        return Result.success("发布成功");


    }

    @GetMapping("/questionGetPage")
    public Result<Page<QuestionsPageVO>> questionGetPage(QuestionsPageDTO QuestionsPageDTO){


        return Result.success(questionsService.getPage(QuestionsPageDTO));

    }


}
